﻿@model ProductDetailsModel
@using Nop.Web.Models.Catalog;
@{
    Layout = "~/Views/Shared/_Root.cshtml";

    //title
    Html.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
}
<div class="page product-details-page">
    <div class="page-body">
        @Html.Widget("mobile_productdetails_top")
        @*we add enctype = "multipart/form-data" because "File upload" attribute control type requries it*@
        @using (Html.BeginRouteForm("Product", new RouteValueDictionary() { { "SeName", Model.SeName } }, FormMethod.Post, new Dictionary<string, Object> { { "data-ajax", "false" }, { "enctype", "multipart/form-data" }, { "id", "product-details-form" } }))
        {
            <div class="product-essential" data-productid="@Model.Id">
                <div class="overview">
                    <h1 class="product-name">
                        @Model.Name
                    </h1>
                    @if (!String.IsNullOrEmpty(Model.ShortDescription))
                    {
                        <div class="short-description">
                            @Html.Raw(Model.ShortDescription)
                        </div>
                    }
                    @Html.Widget("mobile_productdetails_before_pictures")
                    @Html.Partial("_ProductDetailsPictures", Model)
                    @Html.Widget("mobile_productdetails_after_pictures")
                    @Html.Action("ProductManufacturers", "Catalog", new { productId = Model.Id })
                    @Html.Action("ProductReviewOverview", "Catalog", new { productId = Model.Id })
                    @Html.Action("ProductEmailAFriendButton", "Catalog", new { productId = Model.Id })
                    @Html.Action("CompareProductsButton", "Catalog", new { productId = Model.Id })
                </div>
                @if (!String.IsNullOrEmpty(Model.FullDescription))
                {
                    <div class="full-description">
                        @Html.Raw(Model.FullDescription)
                    </div>
                }
            </div>
            <div class="product-collateral">
                <div class="product-variant-list">
                    <!--associated products-->
                    @foreach (var variant in Model.AssociatedProducts)
                    {
                        <div class="product-variant-line" data-productid="@variant.Id">
                            @if (!String.IsNullOrWhiteSpace(variant.DefaultPictureModel.ImageUrl))
                            {
                                <div class="variant-picture">
                                    <img alt="@variant.DefaultPictureModel.AlternateText" src="@variant.DefaultPictureModel.ImageUrl"
                                        title="@variant.DefaultPictureModel.Title" id="main-product-img-@variant.Id" />
                                </div>
                            }
                            <div class="variant-overview">
                                @if (!String.IsNullOrWhiteSpace(variant.Name))
                                {
                                    <div class="variant-name">
                                        @variant.Name
                                    </div>
                                }
                                @if (!String.IsNullOrWhiteSpace(variant.ShortDescription))
                                {
                                    <div class="variant-description">
                                        @Html.Raw(variant.ShortDescription)
                                    </div>
                                }
                                @Html.Partial("_DownloadSample", variant)
                                @Html.Action("ProductTierPrices", "Catalog", new { productId = variant.Id })
                                @{
                                var dataDictAttributes = new ViewDataDictionary();
                                dataDictAttributes.TemplateInfo.HtmlFieldPrefix = string.Format("attributes_{0}", variant.Id);
                                    @Html.Partial("_ProductAttributes", variant.ProductVariantAttributes, dataDictAttributes)                  
                                }
                                <!--product SKU, manufacturer part number, stock info-->
                                @Html.Partial("_SKU_Man_Stock", variant)
                                <!--Back in stock subscription-->
                                @Html.Partial("_BackInStockSubscription", variant)
                                @{
                                var dataDictGiftCard = new ViewDataDictionary();
                                dataDictGiftCard.TemplateInfo.HtmlFieldPrefix = string.Format("giftcard_{0}", variant.Id);
                                    @Html.Partial("_GiftCardInfo", variant.GiftCard, dataDictGiftCard)
                                }
                                @{
                                var dataDictPrice = new ViewDataDictionary();
                                dataDictPrice.TemplateInfo.HtmlFieldPrefix = string.Format("price_{0}", variant.Id);
                                    @Html.Partial("_ProductPrice", variant.ProductPrice, dataDictPrice)
                                }
                                @{
                                var dataDictAddToCart = new ViewDataDictionary();
                                dataDictAddToCart.TemplateInfo.HtmlFieldPrefix = string.Format("addtocart_{0}", variant.Id);
                                    @Html.Partial("_AddToCart", variant.AddToCart, dataDictAddToCart)
                                }
                            </div>
                        </div>
                    }
                    @if (Model.AssociatedProducts.Count == 0)
                    {
                        <div class="no-associated-products">
                            @T("Products.NoAssociatedProducts")
                        </div>
                    }
                </div>
                @Html.Action("ProductSpecifications", "Catalog", new { productId = Model.Id })
                @Html.Action("ProductTags", "Catalog", new { productId = Model.Id })
                @Html.Action("ProductsAlsoPurchased", "Catalog", new { productId = Model.Id })
                @Html.Action("RelatedProducts", "Catalog", new { productId = Model.Id })
            </div>
        }
        @Html.Widget("mobile_productdetails_bottom")
    </div>
</div>
